package org.springframework.webflow.wanda;

import java.io.Serializable;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.Hashtable;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "WandaUser")
public class WandaUser implements Serializable {

    private static final long serialVersionUID = -3652559447682574722L;

    private String username;
    private String password;

    private String firstName;
    private String lastName;

    private String emailAdress;
    private Date birthDate;
    private Timestamp createdTS;
    private Timestamp modifiedTS;
    private String authority;
    private boolean aktive;

    @OneToMany(mappedBy = "articles", cascade = CascadeType.ALL)
    private Hashtable<String, Article> articles;

    public WandaUser() {
    }

    public WandaUser(String username, String password, String firstname, String lastname) {
	this.username = username;
	this.password = password;
	this.firstName = firstname;
	this.lastName = lastname;
	setAktive(true);
	createdTS = new java.sql.Timestamp(System.currentTimeMillis());
	modifiedTS = (Timestamp) createdTS.clone();
    }

    @Id
    public String getUsername() {
	return username;
    }

    public void setUsername(String username) {
	this.username = username;
    }

    public String getPassword() {
	return password;
    }

    public void setPassword(String password) {
	this.password = password;
    }

    public String getFirstName() {
	return firstName;
    }

    public void setFirstName(String firstName) {
	this.firstName = firstName;
    }

    public String getLastName() {
	return lastName;
    }

    public void setLastName(String lastName) {
	this.lastName = lastName;
    }

    public String getEmailAdress() {
	return emailAdress;
    }

    public void setEmailAdress(String emailAdress) {
	this.emailAdress = emailAdress;
    }

    public Date getBirthDate() {
	return birthDate;
    }

    public void setBirthDate(Date birthDate) {
	this.birthDate = birthDate;
    }

    public Timestamp getCreatedTS() {
	return createdTS;
    }

    public void setCreatedTS(Timestamp createdTS) {
	this.createdTS = createdTS;
    }

    public Timestamp getModifiedTS() {
	return modifiedTS;
    }

    public void setModifiedTS(Timestamp modifiedTS) {
	this.modifiedTS = modifiedTS;
    }

    public Hashtable<String, Article> getArticles() {
	return articles;
    }

    public void setArticles(Hashtable<String, Article> articles) {
	this.articles = articles;
    }

    @Override
    public String toString() {
	return "User(" + username + ")";
    }

    public boolean isAktive() {
	return aktive;
    }

    public void setAktive(boolean aktive) {
	this.aktive = aktive;
    }

    public String getAuthority() {
	return authority;
    }

    public void setAuthority(String authority) {
	this.authority = authority;
    }
}
